#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin >> n;
    int res = 0;
    for(int i = 0; i < n; ++i) {
        int sum; char pay;
        cin >> sum >> pay;
        if(pay == 'X') continue;
        else if(pay == 'O') {
            res += sum;
        }
    }
    cout << res << endl;
}